﻿using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class ScoreManager
{
    public GUIModule Module;
    public static Vector3 MinScale = new Vector3(.8f, .8f, .8f);
    public static Vector3 MaxScale = new Vector3(1.2f, 1.2f, 1.2f);
    public const float ScaleSpeed = 2f;
    public const float UpSpeed = 5f;
    public const float TextureSize = 0.7f;//一个图片的显示尺寸
    public const float FontCount = 12;//横向图片的数量
    private int deleteIndex = -1;
    public ScoreManager(GUIModule module)
    {
        Module = module;
    }
    public void Update()
    {
        deleteIndex = -1;
        for (int i = 0; i < scoreList.Count; i++)
        {
            ScoreItem item = scoreList[i];
            if (item.End) deleteIndex = i;
            else item.Update();
        }
        if (deleteIndex > -1)
        {
            GameObject.Destroy(scoreList[deleteIndex].Root.gameObject);
            scoreList.RemoveAt(deleteIndex);
        }
    }
    public void ShowScore(Transform transform, int score)
    {
        if(score != 0)
        {
            GameObject obj = GameObject.Instantiate(Resources.Load("Other/score_pre")) as GameObject;
            obj.transform.position = transform.position;
            obj.name = "ScoreInstance_" + obj.GetInstanceID();
            ScoreItem item = new ScoreItem(obj.transform, transform, score);
            scoreList.Add(item);
        }
    }
    private List<ScoreItem> scoreList = new List<ScoreItem>();
}


